# -*- coding: utf-8 -*-

from airtest.core.api import *
from airtest.cli.parser import cli_setup

ip = 250

auto_setup(__file__,
            logdir=None,
            devices=[
                "android://127.0.0.1:5037/192.168.0.{}:5555".format(ip),
            ]
            )


from poco.drivers.android.uiautomation import AndroidUiautomationPoco
poco = AndroidUiautomationPoco(
    use_airtest_input=True, screenshot_each_action=False)
print("start...")


from PIL import Image, ImageFilter
img_name = "hello.jpg"

snapshot(img_name)

im = Image.open(img_name)
print(im.size)

x1,x2,x3,x4 = 247,475,706,939
y1,y2 = 792,1061
poss = [
    (x1, y1),
    (x2, y1),
    (x3, y1),
    (x4, y1),
    (x1, y2),
    (x2, y2),
    (x3, y2),
    # (x4, y2),
]

for pos in poss:
    print(im.getpixel(pos))
    r, g, b = im.split()
    print(b.getpixel(pos))
